package com.ck.service.impl;

import com.ck.service.AsyncThreadService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class AsyncThreadServiceImpl implements AsyncThreadService {

    @Override
    public void sleep() {
        log.warn("sleep ",Thread.currentThread().getName());
        sleep2();
    }

    @Async
    public void sleep2() {
        log.warn("sleep2 start,{}",Thread.currentThread().getName());
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.warn("sleep2 end,{}",Thread.currentThread().getName());
    }
}
